#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QGraphicsItem>
#include <QObject>
#include <QWidget>
#include <QPainter>
#include <QGraphicsEllipseItem>

class QLineEdit;
class QPushButton;
class QHBoxLayout;
class QVBoxLayout;
class QLabel;
class QGraphicsView;
class QGraphicsScene;
class YLCrea;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    void setItem();

private slots:
    void clickButtonSlot(QString inputstr);


private:
    Ui::MainWindow *ui;

    int rowPos[4];

    QLabel *m_showLabel;
    QPushButton *m_clickButton;
    QLineEdit *m_inputLineEdit;

    QHBoxLayout *m_buttonlayout;
    QVBoxLayout *m_mainLayout;

    QGraphicsScene *m_pScene;
    QGraphicsView *m_pView;

    QList<YLCrea *> m_YLList;

};


class YLCrea:public QObject, public QGraphicsItem
{

    Q_OBJECT
 public:
     YLCrea(unsigned int t_num);
    ~YLCrea();

    virtual QRectF boundingRect() const
    {
        //qreal penWidth = 1;
        return QRectF(-50 , -50 , 50, 50);
    }

   virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) ;

    void setFlash(bool flag)
    {
        this->flash = flag;
        this->update(); // 调用paint  重绘
    }

    bool getFlash()
    {
        return this->flash;
    }

private:
    bool flash;
    unsigned int m_Num;

};

#endif // MAINWINDOW_H
